# -*- coding: UTF-8; indent-tabs-mode:nil; tab-width:4 -*-

# This file is part of DITA DTD Generator.
#
# DITA DTD Generator is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DITA DTD Generator is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DITA DTD Generator.  If not, see <http://www.gnu.org/licenses/>.

import ditagen.dita
from ditagen.dtdgen import Attribute as Attribute
from ditagen.dtdgen import ParameterEntity as ParameterEntity

# Elements
#####################################################################

class TopicElement(ditagen.dita.DitaElement):
    """Topic element."""
    _name = u"topic"
    _cls = u"- topic/topic "
    _model = """(%%title;), (%%titlealts;)?,
        (%%shortdesc; | %%abstract;)%(shortdesc)s,
        (%%prolog;)?, (%%body;)?, (%%related-links;)?%(nested)s"""
    #(%%%s-info-types;)*
    _attrs = [
        Attribute("id", "ID", "#REQUIRED"),
        Attribute("conref", "CDATA", "#IMPLIED"),
        ParameterEntity("select-atts"),
        ParameterEntity("localization-atts"),
        ParameterEntity("arch-atts"),
        Attribute("outputclass", "CDATA", "#IMPLIED"),
    ]
class ConceptElement(ditagen.dita.DitaElement):
    """Concept element."""
    _name = u"concept"
    _cls = u"- topic/topic concept/concept "
    _model = """(%%title;), (%%titlealts;)?,
        (%%shortdesc; | %%abstract;)%(shortdesc)s,
        (%%prolog;)?, (%%conbody;)?, (%%related-links;)?%(nested)s"""
    _attrs = [
        Attribute("id", "ID", "#REQUIRED"),
        Attribute("conref", "CDATA", "#IMPLIED"),
        ParameterEntity("select-atts"),
        ParameterEntity("localization-atts"),
        ParameterEntity("arch-atts"),
        Attribute("outputclass", "CDATA", "#IMPLIED"),
    ]        
class TaskElement(ditagen.dita.DitaElement):
    """Task element."""
    _name = u"task"
    _cls = u"- topic/topic task/task "
    _model = """(%%title;), (%%titlealts;)?,
        (%%shortdesc; | %%abstract;)%(shortdesc)s,
        (%%prolog;)?, (%%taskbody;)?,
        (%%related-links;)?%(nested)s"""
    _attrs = [
        Attribute("id", "ID", "#REQUIRED"),
        Attribute("conref", "CDATA", "#IMPLIED"),
        ParameterEntity("select-atts"),
        ParameterEntity("localization-atts"),
        ParameterEntity("arch-atts"),
        Attribute("outputclass", "CDATA", "#IMPLIED"),
    ]
class ReferenceElement(ditagen.dita.DitaElement):
    """Reference element."""
    _name = u"reference"
    _cls = u"- topic/topic reference/reference "
    _model = """(%%title;), (%%titlealts;)?,
        (%%shortdesc; | %%abstract;)%(shortdesc)s,
        (%%prolog;)?, (%%refbody;)?, (%%related-links;)?%(nested)s"""
    _attrs = [
        Attribute("id", "ID", "#REQUIRED"),
        Attribute("conref", "CDATA", "#IMPLIED"),
        ParameterEntity("select-atts"),
        ParameterEntity("localization-atts"),
        ParameterEntity("arch-atts"),
        Attribute("outputclass", "CDATA", "#IMPLIED"),
    ]
class MapElement(ditagen.dita.DitaElement):
    """Map element."""
    _name = u"map"
    _cls = u"- map/map "
    _model = """((%%title;)?, 
       (%%topicmeta;)?, 
       (%%anchor; |
        %%data.elements.incl; |
        %%navref; |
        %%reltable; |
        %%topicref;)*)"""
    _attrs = [
        Attribute("title", "CDATA", "#IMPLIED"),
        Attribute("id", "ID", "#REQUIRED"),
        ParameterEntity("conref-atts"),
        Attribute("anchorref", "CDATA", "#IMPLIED"),
        Attribute("outputclass", "CDATA", "#IMPLIED"),
        ParameterEntity("localization-atts"),
        ParameterEntity("topicref-atts"),
        ParameterEntity("select-atts"),
        ParameterEntity("arch-atts"),
    ]
class BookMapElement(ditagen.dita.DitaElement):
    """BookMap element."""
    _name = u"bookmap"
    _cls = u"- map/map bookmap/bookmap "
    _model = """(((%%title;) | 
        (%%booktitle;))?,
        (%%bookmeta;)?, 
        (%%frontmatter;)?,
        (%%chapter;)*, 
        (%%part;)*, 
        (%%appendix;)*,
        (%%backmatter;)?,
        (%%reltable;)*)"""
    _attrs = [
        Attribute("id", "ID", "#REQUIRED"),
        ParameterEntity("conref-atts"),
        Attribute("anchorref", "CDATA", "#IMPLIED"),
        Attribute("outputclass", "CDATA", "#IMPLIED"),
        ParameterEntity("localization-atts"),
        ParameterEntity("topicref-atts"),
        ParameterEntity("select-atts"),
        ParameterEntity("arch-atts"),
    ]

# Topic types
#####################################################################

class TopicType(ditagen.dita.Type):
    """Topic topic type."""
    _id = u"topic"
    _file = u"topic"
    _title = u"Topic"
    _parent = None
    _root = TopicElement()
class ConceptType(TopicType):
    """Concept topic type."""
    _id = u"concept"
    _file = u"concept"
    _title = u"Concept"
    _parent = TopicType()
    _root = ConceptElement()
class TaskType(TopicType):
    """Task topic type."""
    _id = u"task"
    _file = u"task"
    _title = u"Task"
    _parent = TopicType()
    _root = TaskElement()
class ReferenceType(TopicType):
    """Reference topic type."""
    _id = u"reference"
    _file = u"reference"
    _title = u"Reference"
    _parent = TopicType()
    _root = ReferenceElement()
class MapType(ditagen.dita.Type):
    """Map topic type."""
    _id = u"map"
    _file = u"map" # the .dtd file is at technicalContent
    _title = u"Map"
    _parent = None
    _root = MapElement()
class BookMapType(MapType):
    """BookMap topic type."""
    _id = u"bookmap"
    _file = u"bookmap"
    _title = u"BookMap"
    _parent = MapType()
    _root = BookMapElement()


# Domains
#####################################################################
    
class UiDomain(ditagen.dita.Domain):
    """User interface domain."""
    _id = u"ui-d"
    _file = u"ui"
    _title = u"User Interface"
    _elements = [u"pre", u"keyword", u"ph"]
    _parent = [TopicType]
class HiDomain(ditagen.dita.Domain):
    """Hilight domain."""
    _id = u"hi-d"
    _file = u"highlight"
    _title = u"Highlight"
    _elements = [u"ph"]
    _parent = [TopicType]
class PrDomain(ditagen.dita.Domain):
    """Programmign domain."""
    _id = u"pr-d"
    _file = u"programming"
    _title = u"Programming"
    _elements = [u"pre", u"keyword", u"ph", u"fig", u"dl"]
    _parent = [TopicType]
class SwDomain(ditagen.dita.Domain):
    """Software development domain."""
    _id = u"sw-d"
    _file = u"software"
    _title = u"Software"
    _elements = [u"pre", u"keyword", u"ph"]
    _parent = [TopicType]
class UtDomain(ditagen.dita.Domain):
    """Utilities domain."""
    _id = u"ut-d"
    _file = u"utilities"
    _title = u"Utilities"
    _elements = [u"fig"]
    _parent = [TopicType]
class IndexingDomain(ditagen.dita.Domain):
    """Indexing domain."""
    _id = u"indexing-d"
    _file = u"indexing"
    _title = u"Indexing"
    _elements = [u"index-base"]
    _parent = [TopicType, MapType]
class MapGroupDomain(ditagen.dita.Domain):
    """Map group domain."""
    _id = u"mapgroup-d"
    _file = u"base/dtd/mapGroup"
    _title = u"Map Group"
    _elements = [u"topicref"]
    _parent = [MapType]
class AbbreviatedFormDomain(ditagen.dita.Domain):
    """Abbreviated form domain."""
    _id = u"abbreviate-d"
    _file = u"technicalContent/dtd/abbreviate"
    _title = u"Abbreviated Form"
    _elements = [u"term"]
    _parent = [TopicType]
class XNALDomain(ditagen.dita.Domain):
    """XNAL domain."""
    _id = u"xnal-d"
    _file = u"xnal/dtd/xnal"
    _title = u"XNAL"
    _elements = [u"author"]
    _parent = [MapType]
